#include<iostream>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
bool isnumber(char ch)
{
    if (ch >= '0' && ch <= '9')
    {
        return true;
    }
    return false;
}
string decodeString(string s)
{
    stack<char> s1;
    string s2;
    char ch;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != ']')
        {
            s1.push(s[i]);
        }
        else
        {
            s2.clear();
            while (!s1.empty()&&(ch = s1.top()) != '[')
            {
                s2 += ch;
                s1.pop();
            }
            s1.pop();
            int num = 0;
            int cnt = 1;
            while (!s1.empty()&&isnumber(s1.top()))
            {
                if (cnt == 1)
                {
                    num += s1.top() - '0';
                }
                else if (cnt == 2)
                {
                    num += (s1.top() - '0') * 10;
                }
                else
                {
                    num += (s1.top() - '0') * 100;
                }
                cnt++;
                s1.pop();
            }
            while (num--)
            {
                for (int j = s2.size() - 1; j >= 0; j--)
                {
                    s1.push(s2[j]);
                }
            }
        }
    }
    string answer;
    while (!s1.empty())
    {
        answer += s1.top();
        s1.pop();
    }
    reverse(answer.begin(), answer.end());
    return answer;
}

int main()
{
    string s;
    cin >> s;
    cout << decodeString(s) << endl;
    return 0;
}